<?php
	header("Content-Type: text/html;charset=utf-8");
	include("../_judge.php");
	include("../../function/function.php");
	
	$action = chkstr(trim($_REQUEST['action']));
	$trailfoot_title = chkstr(trim($_REQUEST['trailfoot_title']));
	$trailfoot_pic = chkstr(trim($_REQUEST['trailfoot_pic']));
	$trailfoot_pic2 = chkstr(trim($_REQUEST['trailfoot_pic2']));
	$trailfoot_pic3 = chkstr(trim($_REQUEST['trailfoot_pic3']));
	$trailfoot_pic4 = chkstr(trim($_REQUEST['trailfoot_pic4']));
	$trailfoot_startime = chkstr(trim($_REQUEST['trailfoot_startime']));
	$trailfoot_duration = chkstr(trim($_REQUEST['trailfoot_duration']));
	$trailfoot_line = chkstr(trim($_REQUEST['trailfoot_line']));
	$trailfoot_allline = chkstr(trim($_REQUEST['trailfoot_allline']));
	$trailfoot_power = chkstr(trim($_REQUEST['trailfoot_power']));
	$trailfoot_rise = chkstr(trim($_REQUEST['trailfoot_rise']));
	$trailfoot_drop = chkstr(trim($_REQUEST['trailfoot_drop']));
	$trailfoot_taltitude = chkstr(trim($_REQUEST['trailfoot_taltitude']));
	$trailfoot_baltitude = chkstr(trim($_REQUEST['trailfoot_baltitude']));
	$trailfoot_speed = chkstr(trim($_REQUEST['trailfoot_speed']));
	$trailfoot_writer = chkstr(trim($_REQUEST['trailfoot_writer']));
	$trailfoot_text = chkstr(trim($_REQUEST['trailfoot_text']));
	$trailfoot_map = addslashes($_REQUEST['trailfoot_map']);
	$trailfoot_about = addslashes($_REQUEST['trailfoot_about']);
	$trailfoot_footline = addslashes($_REQUEST['trailfoot_footline']);
	$trailfoot_foot = addslashes($_REQUEST['trailfoot_foot']);
  
	$now_time = date("Y-m-d H:i:s");
	$re_url = trim($_REQUEST['re_url']);
	$newsid = $_REQUEST['newsid'];
	$news_option = chkstr(trim($_REQUEST['news_option']));
	$id = trim($_REQUEST['id']);
	
	
	if(is_array($newsid)){ // 拆分数组
		$newsid = implode(',',$newsid);
	}
	if($action == "add"){
		if(strlen($trailfoot_title)<1){
			echo erro("请将信息填写完整");
		}
		
		// 添加数据
		$mysql = new sqlstr("kboy_trailfoot"); 
		$mysql -> set("trailfoot_title",$trailfoot_title);
		$mysql -> set("trailfoot_pic",$trailfoot_pic);
		$mysql -> set("trailfoot_pic2",$trailfoot_pic2);
		$mysql -> set("trailfoot_pic3",$trailfoot_pic3);
		$mysql -> set("trailfoot_pic4",$trailfoot_pic4);
		$mysql -> set("trailfoot_startime",$trailfoot_startime);
		$mysql -> set("trailfoot_duration",$trailfoot_duration);
		$mysql -> set("trailfoot_line",$trailfoot_line);
		$mysql -> set("trailfoot_allline",$trailfoot_allline);
		$mysql -> set("trailfoot_power",$trailfoot_power);
		$mysql -> set("trailfoot_rise",$trailfoot_rise);
		$mysql -> set("trailfoot_drop",$trailfoot_drop);
		$mysql -> set("trailfoot_taltitude",$trailfoot_taltitude);
		$mysql -> set("trailfoot_baltitude",$trailfoot_baltitude);
		$mysql -> set("trailfoot_speed",$trailfoot_speed);
		$mysql -> set("trailfoot_writer",$trailfoot_writer);
		$mysql -> set("trailfoot_text",$trailfoot_text);
		$mysql -> set("trailfoot_map",$trailfoot_map);
		$mysql -> set("trailfoot_about",$trailfoot_about);
		$mysql -> set("trailfoot_footline",$trailfoot_footline);
		$mysql -> set("trailfoot_foot",$trailfoot_foot);
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo ok("操作成功","newsadd.php");
		}else{
			echo erro("服务器内部错误");
		}

	}elseif($action == "edit"){
		if(strlen($trailfoot_title)<1 || strlen($id)<1){
			echo erro("请将信息填写完整");
		}
		if(!is_numeric($id)){
			echo erro("ID错误");
		}

		// 修改数据
		$mysql = new sqlstr("kboy_trailfoot"); 
		$mysql -> set("trailfoot_title",$trailfoot_title);
		$mysql -> set("trailfoot_pic",$trailfoot_pic);
		$mysql -> set("trailfoot_pic2",$trailfoot_pic2);
		$mysql -> set("trailfoot_pic3",$trailfoot_pic3);
		$mysql -> set("trailfoot_pic4",$trailfoot_pic4);
		$mysql -> set("trailfoot_startime",$trailfoot_startime);
		$mysql -> set("trailfoot_duration",$trailfoot_duration);
		$mysql -> set("trailfoot_line",$trailfoot_line);
		$mysql -> set("trailfoot_allline",$trailfoot_allline);
		$mysql -> set("trailfoot_power",$trailfoot_power);
		$mysql -> set("trailfoot_rise",$trailfoot_rise);
		$mysql -> set("trailfoot_drop",$trailfoot_drop);
		$mysql -> set("trailfoot_taltitude",$trailfoot_taltitude);
		$mysql -> set("trailfoot_baltitude",$trailfoot_baltitude);
		$mysql -> set("trailfoot_speed",$trailfoot_speed);
		$mysql -> set("trailfoot_writer",$trailfoot_writer);
		$mysql -> set("trailfoot_map",$trailfoot_map);
		$mysql -> set("trailfoot_text",$trailfoot_text);
		$mysql -> set("trailfoot_about",$trailfoot_about);
		$mysql -> set("trailfoot_footline",$trailfoot_footline);
		$mysql -> set("trailfoot_foot",$trailfoot_foot);
		$news_sql = $mysql -> updateSql("id=$id");
		$news_res = mysql_query($news_sql);
		if($news_res){
			echo ok("操作成功",$re_url);
		}else{
			echo erro("服务器内部错误");
		}
		
	}elseif($action == "del"){
		if($news_option == "del"){
			if(!empty($newsid)){
				// 删除数据
				$mysql = new sqlstr("kboy_trailfoot"); 
				$news_sql = $mysql -> deleteSql("id in($newsid)");
				$news_res = mysql_query($news_sql);
				if($news_res){
					echo ok("操作成功",$_SERVER['HTTP_REFERER']);
				}else{
					echo erro("服务器内部错误");
				}
			}else{
				echo erro("至少选择一条记录进行操作");
			}
		}elseif($news_option == "istui"){
			if(!empty($newsid)){
				$mysql = new sqlstr("kboy_trailfoot"); 
				$mysql -> set("trailfoot_tui",1,true);
				$news_sql = $mysql -> updateSql("id in($newsid)");
				$news_res = mysql_query($news_sql);
				if($news_res){
					echo ok("操作成功",$_SERVER['HTTP_REFERER']);
				}else{
					echo erro("服务器内部错误");
				}
			}else{
				echo erro("至少选择一条记录进行操作");
			}
		}elseif($news_option == "notui"){
			if(!empty($newsid)){
				$mysql = new sqlstr("kboy_trailfoot"); 
				$mysql -> set("trailfoot_tui",0,true);
				$news_sql = $mysql -> updateSql("id in($newsid)");
				$news_res = mysql_query($news_sql);
				if($news_res){
					echo ok("操作成功",$_SERVER['HTTP_REFERER']);
				}else{
					echo erro("服务器内部错误");
				}
			}else{
				echo erro("至少选择一条记录进行操作");
			}
			
			
			
		}else{
			erro("请选择要操作的方式");
		}
	
	}else{
		echo erro("参数错误");
	}
	
?>
